<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('鸡入库列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">

					<div class="btn-group " style="margin: 0px auto;display: table;" role="group">

						<button type="button" class="top-link btn-sm btn-white">农事</button>
						<button type="button" class="top-link btn-sm btn-primary">鸡入库</button>
						<button type="button" class="top-link btn-sm btn-white">鸡出库</button>
					</div>

				<!--<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								入栏批次：<input type="text" name="inputCode"/>
							</li>

							<li>
								入栏鸡品种： 字典：<input type="text" name="inputVarieties"/>
							</li>

							<li>
								供应商：<input type="text" name="supplier"/>
							</li>

							<li>
								合格证（有/无）：<input type="text" name="isHege"/>
							</li>

							<li>
								数量（只)：<input type="text" name="inputAmount"/>
							</li>

							<li>
								入栏时间：<input type="text" name="inputTime"/>
							</li>

							<li>
								入栏经手人：<input type="text" name="inputUser"/>
							</li>

							<li>
								创建者：<input type="text" name="createBy"/>
							</li>

							<li>
								创建时间：<input type="text" name="createTime"/>
							</li>

							<li>
								备注：<input type="text" name="remark"/>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>-->
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncInputChicken:add">
					<i class="fa fa-plus"></i> 新增
				</a>
				<a class="btn btn-warning" onclick="confirmTable();">
					<i class="fa fa-send"></i> 单据确认
				</a>
				<a class="btn btn-primary " onclick="openOrder();">
					<i class="fa fa-table"></i> 入库单管理
				</a>
				<!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:ncInputChicken:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:ncInputChicken:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:ncInputChicken:export">
						<i class="fa fa-download"></i> 导出
				 </a>-->
			</div>
			<div class="col-sm-12 select-table table-striped">
				<h3 style="width:100%;text-align:center;">存栏数量：<span  style="color: #1c84c6;" th:text="${chickStackAamount}">23</span><span style="color: #1c84c6;">只</span> &nbsp;&nbsp; 主饲料库存：<span style="color: #1c84c6;" th:text="${zFfeed}">23</span><span style="color: #1c84c6;">kg</span>  &nbsp;&nbsp; 辅饲料库存：<span style="color: #1c84c6;" th:text="${fFfeed}">23</span><span style="color: #1c84c6;">kg</span></h3>
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>

		</div>
		 <div class="bottom-btns"></div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:ncInputChicken:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:ncInputChicken:remove')}]];
        var prefix = ctx + "system/ncInputChicken";
		//入栏鸡品种
		var chickentype= [[${@dict.getType('chicken_type')}]];
		//检疫合格证
		var chickenIsHege=[[${@dict.getType('chickenIsHege')}]];
        $(function() {
            var options = {
                url: prefix + "/list?inputStatus=1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "鸡入库",
                showExport: false,
                showSearch: false,
                showRefresh: false,
                showColumns: false,
                showToggle: false,
                sortName:'inputTime',
                sortOrder:'desc',
                showFooter: false,
                columns: [
                    {
                        title: '序号',
                        formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                        },
                        footerFormatter: function () {
                            return '合计'
                        }
                    },
				{
					field : 'inputVarieties', 
					title : '入栏鸡品种',
					sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(chickentype, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
				},
				{
					field : 'supplier', 
					title : '供应商',
					sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
				},
				{
					field : 'isHege', 
					title : '检疫合格证（有/无）',
					sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(chickenIsHege, value);
                    },
                    footerFormatter: function () {
                        return '-'
                    }
				},
				{
					field : 'inputAmount', 
					title : '数量（只）',
					sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.inputAmount;
                        });
                        return count;

                    }
				},
				{
					field : 'inputTime', 
					title : '入栏时间',
					sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
				},
				{
					field : 'inputUser', 
					title : '入栏经手人',
					sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
				},

				{
					field : 'remark', 
					title : '备注',
					sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.inputId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.inputId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
            var btns = [
                {
                    name: "宰杀管理",
                    url: ctx + 'system/ncZaisha',
                    id: 'Zaisha-work'
                },
                {
                    name: "主饲料",
                    url: ctx + 'system/ncChickenFeed?feedType=1',
                    id: 'Feed-work'
                },
                {
                    name: "辅饲料",
                    url: ctx + 'system/ncChickenFeed2?feedType=2',
                    id: 'Feed2-work'
                },
                {
                    name: "消毒记录",
                    url: ctx + 'system/ncChickenDisinfection',
                    id: 'Disinfection-work'
                },
                {
                    name: "兽医请求",
                    url: ctx + 'system/ncChickenZhenliaoLogs',
                    id: 'zhenliao-work'
                },
				{
					name: "所有诊疗记录",
					url: ctx + 'system/ncChickenZhenliaoLogs/allZhenliao',
					id: 'zhenliaojilu'
				},
                {
                    name: "诊疗单",
                    url: ctx + 'system/ncOrder?orderType=17',
                    id: 'ncZhenliaoLogs-work'
                },
                {
                    name: "日报表",
                    url: ctx + 'system/ncChickenDayCensus',
                    id: 'chicken_day'
                },
                {
                    name: "月报表",
                    url: ctx + 'system/ncChickenMonthCensus',
                    id: 'chicken_month'
                },
                {
                    name: '工作记录',
                    url: ctx + 'system/ncNormalWorks?workType=9',
                    id: 'normal-work'
                },
                {
                    name: '所有出库',
                    url: ctx + 'system/ncOutputChicken/ncOutputChickenAll',
                    id: 'ncOutputChickenAll'
                }

            ]
            addBtns(btns);
            $('.top-link').click(function () {
                var index = $(this).index();
                switch (index) {
                    case 0:
                        window.location.href = ctx + 'system/ncChickenWorkNotice';
						return;
                    case 1:
                        window.location.reload();
                        return;
                    case 2:
                        window.location.href = ctx + 'system/ncOutputChicken';
                        return;
                }
            })
        });
        /*表单确认*/
        function confirmTable() {
            var confirmTable = prefix + "/confirmTable";
            var data = $('#bootstrap-table').bootstrapTable('getData');
            if (data && data.length > 0) {

                $.modal.confirm("确认生成订单吗？", function () {
                    var ids = [];
                    $(data).each(function (i, e) {
                        ids.push(e.inputId);
                    });
                    var ids_str = ids.join(",");
                    myPost(confirmTable, {ids: ids_str},
                        function (data) {

                            if (data.code == 0) {
                                layer.msg("提交成功")
                            } else {
                                layer.msg(data.msg);
                            }
                            reload()
                        }, function (e) {
                            layer.msg("确认失败!");
                            reload()
                        })

                })
            } else {
                layer.msg("未发现数据!")
            }

        }
        /*打开检测记录单*/
        function openOrder() {

            var url = ctx + 'system/ncOrder?orderType=12 ';

            $.modal.openTab("检测记录单", url);
        }
        function reload() {
            $.table.refresh();
        }
        setTitle("鸡舍管理-鸡入库",false)
    </script>
</body>
</html>